package com.rxh.controller;

import com.rxh.cache.BaseCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * User: 陈俊雄
 * Date: 2018/8/28
 * Time: 11:00
 * Project: Management
 * Package: com.rxh.controller
 */
@Controller
@RequestMapping(value = "/cache")
public class CacheController {
    private final ApplicationContext applicationContext;

    @Autowired
    public CacheController(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @RequestMapping(value = "/refresh")
    @ResponseBody
    public String refresh(@RequestBody String beanName) {
        BaseCache baseCache = applicationContext.getBean(beanName, BaseCache.class);
        System.out.println(baseCache.refreshCache());
        return "Ok";
    }
}